﻿using System;
using System.Data;
using System.Collections.Generic;
using SF.Model;
namespace SF.BLL
{
    /// <summary>
    /// bs_good_order
    /// </summary>
    public partial class bs_good_order
    {
        private readonly SF.DAL.bs_good_order dal = new SF.DAL.bs_good_order();
        public bs_good_order()
        { }
        #region  BasicMethod
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(long id)
        {
            return dal.Exists(id);
        }

        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string where)
        {
            return dal.Exists(where);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(SF.Model.bs_good_order model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SF.Model.bs_good_order model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(long id)
        {

            return dal.Delete(id);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string where)
        {
            return dal.Delete(where);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string idlist)
        {
            return dal.DeleteList(idlist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SF.Model.bs_good_order GetModel(long id)
        {

            return dal.GetModel(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SF.Model.bs_good_order GetModel(string where)
        {
            return dal.GetModel(where);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<SF.Model.bs_good_order> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<SF.Model.bs_good_order> DataTableToList(DataTable dt)
        {
            List<SF.Model.bs_good_order> modelList = new List<SF.Model.bs_good_order>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                SF.Model.bs_good_order model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public int GetRecordCount(string strWhere)
        {
            return dal.GetRecordCount(strWhere);
        }
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }
        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public List<SF.Model.bs_good_order> GetModelList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            DataSet ds = dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
            return DataTableToList(ds.Tables[0]);
        }

        #endregion  BasicMethod
        #region  ExtensionMethod
        /// <summary>
        /// 计算某个字段的总和值
        /// </summary>
        /// <param name="field">字段</param>
        /// <param name="where">条件</param>
        /// <returns></returns>
        public DataSet GetSumField(string field, string where)
        {
            return dal.GetSumField(field, where);
        }

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        /// <param name="pageSize">每页记录数</param>
        /// <param name="pageIndex">当前页数</param>
        /// <param name="pageIndex">查询条件</param>
        /// <param name="filedOrder">排序字段，多个则用“,”隔开</param>
        /// <param name="recordCount">记录总数</param>
        /// <param name="isOut">仅用于前台 订单列表 展示</param>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount, string isOur)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out  recordCount, isOur);
        }
        #endregion  ExtensionMethod
    }
}

